home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Line.h
-
- Contains: xxx put contents here xxx
-
- Written by: Essam Zaky
-
- Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <2> 1/4/94 EZ clean up
- <1> 1/4/94 EZ first checked in
-
- */
-
-
- #ifndef _Line_
- #define _Line_
-
- #ifndef _ToolBoxDump_
- #include "ToolBoxDump.h"
- #endif
-
- #ifndef _TextensionCommon_
- #include "TextensionCommon.h"
- #endif
-
- #ifndef _Array_
- #include "Array.h"
- #endif
-
- #ifndef _StyledText_
- #include "StyledText.h"
- #endif
-
- #ifdef txtnRulers
- #ifndef _RulersRanges_
- #include "RulersRanges.h"
- #endif
-
- #ifndef _RulerObject_
- #include "RulerObject.h"
- #endif
- #endif
-
- //***************************************************************************************************
-
-
- struct TCharLocs {
- Fixed leftEdge;
- Fixed pixWidth;
- };
- const short kMaxLineCharsLocs = 3; // 3 is the max nbr of discontinued char ranges
-
-
- //***************************************************************************************************
-
- class CLine : public HandleObject {
-
- public:
- static void Start();
- static void Terminate();
-
- CLine();
-
- #ifdef txtnRulers
- void ILine(CStyledText* lineText, char direction, CRulersRanges* rulersRanges, TSize sizeInfo = kLargeSize);
- #else
- void ILine(CStyledText* lineText, char direction, TSize sizeInfo = kLargeSize);
- #endif
-
- void Free();
-
- void SetLineInfo(long lineStart, short lineLen, short maxLineWidth);
-
- void Draw(const Rect* lineRect, short lineAscent);
-
- inline void Invalid() {fStart = -1;}
-
- #ifdef txtnScal
- void SetScale(Point numer, Point denom);
- #endif
-
- void SetDirection(char newDirection);
-
- short RunCharsLocs(short startOff, short endOff, short runVisIndex
- , Fixed* startPix, Fixed* pixWidth, Fixed* runLeft, Boolean lineBounds);
-
-
- void LineCharsLocs(TOffsetRange charRange, TCharLocs* charLocsArr, Boolean lineBounds, char caretDir = kRunDir);
-
- CRunObject* Pixel2Character(Fixed hPixel, TOffsetRange* charRange);
-
- short Character2Pixel(TOffset charOffset, char caretDir = kRunDir);
-
- Boolean Visible2BackOrder(TOffset* charOffset, char runDir);
-
- short GetRunDirection(const TLineRun* runInfo); //public since called from "RunDirProc" which can't be a method
-
- private:
- CStyledText* fStyledText;
- CRunsRanges* fRunsRanges;
-
- #ifdef txtnRulers
- CRulersRanges* fRulersRanges;
- CRulerObject* fLineRuler;
- #endif
-
- long fStart;
- short fVisLen;
- Boolean fNoDraw;
- char fDirection;
-
- #ifdef txtnScal
- Point fNumer;
- Point fDenom;
- #endif
-
-
- CArray* fOrderedRuns; // array of TLineRun contains the runs in their visible order
-
- short fLastRun;
-
- Fixed fLeftEdge;
- Fixed fMaxWidth;
-
-
- #ifdef txtnNever
- JustStyleCode RunPosition(short runVisOrder);
- #endif
-
- void DoPixel2Char(TLineRun* runInfo, Fixed pixelWidth, short runVisOrder, TOffsetRange* charRange);
- Fixed DoChar2Pixel(TLineRun* runInfo, short offset, short runVisOrder);
- void DoDrawJust(TLineRun* runInfo, const Rect* lineRect, short lineAscent, Fixed runLeftEdge
- , short runVisOrder);
-
- #ifdef txtnRulers
- Fixed DoFullJustifPortion(TLineRun* runInfo, short runVisOrder);
- #endif
-
- Fixed DoMeasure(TLineRun* runInfo);
-
-
- void InsertRun(long runStart, short runLen, CRunObject* runObj, CArray* unorderedRuns);
-
- #ifdef txtnAdvRulers
- Fixed CalcAlignTabWidth(TPendingTab* pendingTab, Fixed tabTrailWidth, const TLineRunPtr runAfter);
- #endif
-
- void DefineRuns(long lineStart, short lineLen, CArray* unorderedRuns);
-
- short CalcVisibleLength(CArray* theRuns, short lineLen, short* blankRuns);
-
- void OrderRuns(CArray* unorderedRuns);
-
- Fixed DefineRunWidths(CArray* unorderedRuns, Fixed maxWidth);
-
- #ifdef txtnRulers
- Fixed GetPortionRuns(Fixed* portionRunArr, short* cFullJustifRuns);
-
- void DefineExtraRunWidths(Fixed theSlope);
- #endif
-
- short Char2Run(TOffset charOffset, Fixed* runLeftEdge= nil);
-
- short Pixel2Run(Fixed* hPix);
- };
-
- //**************************************************************************************************
-
- #endif
-
-